<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>检查类的实例</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reflectionclass.isfinal.html">ReflectionClass::isFinal</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reflectionclass.isinstantiable.html">ReflectionClass::isInstantiable</a></div>
 <div class="up"><a href="class.reflectionclass.html">ReflectionClass</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="reflectionclass.isinstance" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionClass::isInstance</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">ReflectionClass::isInstance</span> &mdash; <span class="dc-title">检查类的实例</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionclass.isinstance-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>ReflectionClass::isInstance</strong></span>
    ( <span class="methodparam"><span class="type">object</span> <code class="parameter">$object</code></span>
   )</div>

  <p class="para rdfs-comment">
   检查对象是否为一个类的实例。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionclass.isinstance-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">object</code></em></dt>

     <dd>

      <p class="para">
       待比较的对象。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionclass.isinstance-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionclass.isinstance-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5109">
    <p><strong>Example #1 <span class="methodname"><strong>ReflectionClass::isInstance()</strong></span> 相关例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Example&nbsp;usage<br /></span><span style="color: #0000BB">$class&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ReflectionClass</span><span style="color: #007700">(</span><span style="color: #DD0000">'Foo'</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">$class</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isInstance</span><span style="color: #007700">(</span><span style="color: #0000BB">$arg</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Yes"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Equivalent&nbsp;to<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$arg&nbsp;</span><span style="color: #007700">instanceof&nbsp;</span><span style="color: #0000BB">Foo</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Yes"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Equivalent&nbsp;to<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">is_a</span><span style="color: #007700">(</span><span style="color: #0000BB">$arg</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Foo'</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Yes"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Yes
Yes
Yes
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionclass.isinstance-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="reflectionclass.isinterface.html" class="methodname" rel="rdfs-seeAlso">ReflectionClass::isInterface()</a> - 检查类是否是一个接口（interface）</span></li>
    <li class="member"><a href="language.operators.type.html" class="link">类型运算符（instanceof）</a></li>
    <li class="member"><a href="language.oop5.interfaces.html" class="link">对象接口</a></li>
    <li class="member"><span class="function"><a href="function.is-a.html" class="function" rel="rdfs-seeAlso">is_a()</a> - 如果对象属于该类或该类是此对象的父类则返回 TRUE</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reflectionclass.isfinal.html">ReflectionClass::isFinal</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reflectionclass.isinstantiable.html">ReflectionClass::isInstantiable</a></div>
 <div class="up"><a href="class.reflectionclass.html">ReflectionClass</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
